Log In  
BBS > Lexaloffle Community Superblog
This is a combined feed of all Lexaloffle user blogs. For Lexaloffle-related news, see @zep's blog.

All | Following | PICO-8 | Voxatron | General | Off-site
[ :: Read More :: ]

Hi everyone!

I'm hard at work on a 1-4 player cart, but I've run into a snag when it comes to moving a sprite around in a circle.

I more or less have the movement down (thanks to tonechild), but it looks like the wrong part of the sprite is tracing the circle I want:

(Please excuse the incomplete graphics and such.)

It appears that the upper-left corner of the sprite is tracing the circle here, when I'd really prefer something closer to the center of the sprite. Is there a way to make this happen? Or, if not, is there a workaround any of you might recommend?

Here are the relevant points of my (messy) code. You'll notice the star is able to "trace" the track because it uses the same variables I used to draw the circle.

 --variables
 scene="logo"
 last=time()
 game_over=false   --determines that a solo player has lost
 player_win=false  --determines that a player won in multiplayer
 radius1=55  --determines outer circle size
 radius2=25  --determines inner circle size
 originx=63  --center of screen/track
 originy=63  --center of screen/track
 flashcol=11

 --star 1 data
 star1={}
  star1.exist=false
  star1.angle=13
  star1.x=originx+radius1*cos(star1.angle/360)
  star1.y=originy+radius1*sin(star1.angle/360)
  star1.speed=3
  star1.sprite=56
--moves stars along track
 function move_stars()
  --moves star 1
   star1.angle+=star1.speed
   star1.x=originx+radius1*cos(star1.angle/360)
   star1.y=originy+radius1*sin(star1.angle/360)
   if star1.angle>360 then star1.angle=0
   elseif star1.angle<0 then star1.angle=360
   end
 end
 --draws track that stars follow
 function draw_track()
  circ(originx,originy,radius1,2)
  circ(originx,originy,radius2,2)
 end 

Thank you for reading, and for considering the problem! I promise I'll be a better forum participant in the near future, when I know a bit more about this whole Lua thing.

P#73965 2020-03-16 01:54
[ :: Read More :: ]

Thought it'd be fun to share this.

An attempt at capturing even the smallest amount of joy my dog gets from playing fetch.

  • Left/Right to run
  • X to jump
  • Z to bark
  • Down to sit

[0x0]

Cart #fetch-0 | 2020-03-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

P#73961 2020-03-15 22:57 ( Edited 2020-03-15 22:59)
[ :: Read More :: ]

Hello, first post here.

I just got started with Pico-8 recently, and have learned about the usefulness of storing data in strings to get around token limits. I was wondering, can I build a data string using a p8 program, then output that string as text that can be fed into another p8 program without it being reformatted? I'm working on a graphical level-editor program that will output level data strings usable by another cart.

I tried using printh(), but when I opened the text file it mangled up the extended character glyphs and didn't preserve the 4x3 font lower-case letters I had in the string. My goal is to have all 121 characters available so I can store about 7 bits per character, instead of the 4 possible with hexadecimal, if this is possible.

Thanks.

P#73959 2020-03-15 22:20
[ :: Read More :: ]

Cart #maxbize_superbreakout_1-4 | 2020-03-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
5

Hey everyone! This is a Work-In-Progress of my first PICO-8 game, Super Breakout! It only comes with 8 simple levels, but features a fully-functional level editor so that you can create and share your own levels! I still need to add audio, create more levels, and generally polish things up before I'd call this "done." I'm looking for feedback on anything you want to comment on. I'd also love to play any levels you create! Just share the level code in a comment :)

Controls

In-game

  • Left & Right Arrows - Move
  • C | Z - Boost
  • V | X - Launch glued balls
  • Up Arrow - Reset balls
  • Down Arrow - Restart level

Level Editor (mouse required)

  • Left Click - Place brick
  • Right Click - Copy brick
  • Middle Click - Erase brick
  • Left & Right Arrows - Change brick
  • C | Z - Copy level to clipboard (You can share this in a comment below!)
  • V | X - Paste level from clipboard (You can paste in levels that others have created!)
  • Up Arrow - Play level
P#73955 2020-03-15 19:54 ( Edited 2020-03-15 20:01)
[ :: Read More :: ]

Repro:

  • fire up PICO-8
  • switch to code editor
  • type something like 123456789 and hit enter
  • copy and paste that line few times to give yourself something to cursor through
  • using the keyboard, navigate to the middle of one of these lines
  • cursor up and down: should work normally
  • click near the start or end of the line
  • cursor up or down: will change the row properly but maintain the column from before the click

Demo:

This is probably as easy to fix as just setting both the current and virtual column on mouse clicks.

P#73943 2020-03-15 08:42 ( Edited 2020-03-15 08:42)
[ :: Read More :: ]

So I find that organizing my code with data structures and functions adds a lot to the runtime cost in PICO-8.

For example, doing vector math with objects like {x=1,y=2}, and functions like

function vadd(v1,v2)
  return {x=v1.x+v2.x,y=v1.y+v2.y}
end

greatly increases the readability of my code, but at the cost of significant performance hit.

Coming from a C++ background, this really upsets me. Modern C++ compilers are extremely good at optimising, and it's often possible to write very expressive code with almost zero overhead. While in PICO-8, if I want my code to go fast, I have to write it in a rather repetitive and messy way.

I like how PICO-8 is deliberately restrictive, but is there a way to write clean code without hurting performance too much? What are your thoughts?

P#73940 2020-03-15 06:28
[ :: Read More :: ]

Cart #smooth_movement-0 | 2020-03-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3


A small cart I made with some simple movement that is very smooth.
It's left/right with up arrow for jump and down arrow for smash down.

P#73938 2020-03-15 02:27 ( Edited 2020-03-15 02:29)
[ :: Read More :: ]

Cart #cyberbabble-1 | 2020-03-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

This is a work in progress puzzle game, in it there are just 7 levels to get a sense of the mechanics.

P#73906 2020-03-14 23:26 ( Edited 2020-03-15 14:03)
[ :: Read More :: ]

i've been running into some strange errors involving a project using #include while running it on windows instead of my usual linux environment. i've isolated the problem to line ending convention: an external file that uses the windows CrLf convention, but is otherwise the same as a file that works with no problems, will cause errors. here is the text of the external file i used:

local function _draw()
    cls(1)
end

to see the problem, save this with an external text editor using windows line ending convention (wordpad works, as do many programmer text editors) and use #include to include it in a cart.

P#73920 2020-03-14 18:08
[ :: Read More :: ]

The heavens receded like a scroll being rolled up, and every mountain and island was removed from its place. Then the kings of the earth, the princes, the generals, the rich, the mighty, and everyone else, both slave and free, hid in caves and among the rocks of the mountains. They called to the mountains and the rocks:

“SAVE US FROM THIS DEMON!"

.....

Score the number of the beast
to release the world from

PONGATORY!

Controls:

Left & Right to move.
X to serve.

Cart #pongatory-0 | 2020-03-14 | Code ▽ | Embed ▽ | No License
15

Check it out on itch!
https://hotslice.itch.io/pongatory

P#73915 2020-03-14 10:39
[ :: Read More :: ]

Cart #endlessrunner-0 | 2020-03-14 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
14

Just experiencing with an "Impossible Game"- or "Geometry Dash"-like Prototype. Basic Gameplay works, but every other Thing is unfinished at this point^^.

P#73914 2020-03-14 09:15
[ :: Read More :: ]

Cart #birb_tweetcart-0 | 2020-03-14 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
35

Turn with the left and right arrows keys.
If you fall to the ground you can restart the cart (⏸ -> "reset cart").

x=9y=9u=0v=0 function _update60()cls(7)v+=.07l=sqrt(u*u+v*v)a=atan2(u,v)
if(btn(0))a+=.014
if(btn(1))a-=.014
w=.03-cos(a*2)/50u=l*cos(a)v=l*sin(a)x=(x+u+8)%144-8 y+=v
if(y>120)u*=.9v/=-2y=120
for b=a-w,a+w,w*2 do e=x-8*cos(b)line(x,121,e,121,6)line(x,y,e,y-8*sin(b),0)end end

Annotated:

-- Position
x=9
y=9

-- Velocity
u=0
v=0

function _update60()
  cls(7)

  -- Gravity!
  v+=.07

  -- Convert velocity into polar representation (length and angle).
  l=sqrt(u*u+v*v)
  a=atan2(u,v)

  -- Input! Rotate the angle based on arrow keys:
  -- Left  -> counterclockwise
  -- Right -> clockwise
  if(btn(0))a+=.014
  if(btn(1))a-=.014

  -- Convert velocity from polar back into cartesian.
  u=l*cos(a)
  v=l*sin(a)

  -- Update position using velocity!
  -- x is wrapped around the edges. We could just use x=x%128, but then you
  -- would see the bird teleport at the edges. Instead we add 8px of buffer
  -- at each edge.
  x=(x+u+8)%144-8
  y+=v

  -- Simple bounce at the bottom of the screen.
  -- u*=.9 slightly slows the horizontal velocity
  -- v/=-2 reverse and halves the vertical velocity
  -- y=120 pops it back above the bounce breakpoint
  if(y>120) u*=.9 v/=-2 y=120

  -- The bird is drawn using lines that start at the current position and extend
  -- in the direction opposite of the velocity.
  -- We'll add/subtract w from the polar angle to get the different
  -- angles of the two lines.
  w=.03-cos(a*2)/50

  for b=a-w,a+w,w*2 do
    -- The x position of the tail.
    e=x-8*cos(b)

    -- The shadow
    line(x,121,e,121,6)

    -- The bird
    line(x,y,e,y-8*sin(b),1)
  end
end

P#73903 2020-03-14 05:13 ( Edited 2020-03-14 05:22)
[ :: Read More :: ]

Cart #theninjawip-1 | 2020-03-15 | Code ▽ | Embed ▽ | No License


Version 1

This is my first project, I wanted to put it online to show my friends. If any poor soul stumbles upon this game 1. I'm sorry 2. if you really want any feedback would be nice.

Version 0

Cart #theninjawip-0 | 2020-03-14 | Code ▽ | Embed ▽ | No License

P#73898 2020-03-14 02:59 ( Edited 2020-03-15 22:12)
[ :: Read More :: ]

Cart #dungeonsongtest-0 | 2020-03-14 | Code ▽ | Embed ▽ | No License
8

This is just a small loop I've been working on which I plan to put in one of my games, but thought I'd upload it to see what others think. It doesn't use any custom instruments and so far any additional layers I've attempted to add (drums, other melodies, etc.) haven't really sounded right. I'm curious if folks think this loop stands on its own enough or if it would become annoying to listen to after a while. Any general feedback is welcome.

P#73896 2020-03-14 00:23
[ :: Read More :: ]

@zep

Right now if you want to draw a line loop with the cool line(x,y) continuation method, you still have to do at least one line(x0,y0,x1,y1) first to make it work:

-- draw a simple triangle
line(32,96,96,96) -- base
line(64,32)       -- right side
line(32,96)       -- left side

This isn't so bad if you're drawing the figure manually as I just did. But if you're, say, drawing an algorithmic figure's loop, you have to handle that first line conditionally within the loop:

-- draw a simple segmented circle
local cx,cy,r=64,64,32
for a=0,1,0x.01 do
  local x,y=cx+cos(a)*r,cy+sin(a)*r
  if a==0 then
    line(x,y,x,y) -- sets the continuation point
  else
    line(x,y)     -- continued from the last point
  end
end

Or (not shown) you can remove the condition from the loop, but it requires doing math to get the first point outside of the loop and then calling line(x,y,x,y) as above before looping over the subsequent points.

All in all, neither is really better in terms of code than just drawing a series of distinct line(xi,yi,xj,yj) segments.

However, let's say line() with no args invalidates the last position. Let's also say that trying to continue via line(x,y) from an invalid position draws either nothing or just the one pixel, but it does update the last position. Suddenly everything gets a heck of a lot more concise and elegant:

-- draw a simple segmented circle
local cx,cy,r=64,64,32
line()
for a=0,1,0x.01 do
  line(cx+cos(a)*r,cy+sin(a)*r)
end

This should be safe in terms of backcompat, because line() with no args doesn't currently do anything useful, and in fact I'd consider it an undocumented usage that would have been ill-advised to use anyway. Similarly, since there was no such thing as an invalid last point in the past, no one would have written line-continuation code that didn't first update it explicitly in a way that would still work with this change in place.

P#73895 2020-03-13 23:51
[ :: Read More :: ]

Have a nice birthday!
[0x0]
[0x0]

Cart #purlbday2020-0 | 2020-03-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

P#73892 2020-03-13 22:09
[ :: Read More :: ]

With many thanks to packbat for helping me in the forum, I can finally say my first real cart is complete!

I give you: BASTARD SQUASH.

Cart #bastard_squash_v1-0 | 2020-03-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

I don't have any training in programming or math, so this isn't as impressive as most debut carts. Still, we all have to start somewhere! I hope you find something to enjoy in it. Also, don't mind the unused sound samples, and general code inelegance...

Description

Have you ever thought your game of squash needed to hate you a little more? Then do I have a cart for you!

Your paddle shrinks with each successive hit. Past certain point thresholds, it also begins to creep toward the ceiling. Extra lives are granted every 300 points, because I love you, even if my game doesn't.

Controls

  • LEFT/RIGHT: Move the paddle
  • X (x): Hold to increase paddle speed
  • Z (o): Hold to decrease paddle speed

(EDIT: Added link to packbat's user profile for better crediting.)

P#73884 2020-03-13 15:33 ( Edited 2020-03-13 15:35)
[ :: Read More :: ]

I'm looking for some advice on how to grant the player extra lives after the score crosses a certain point interval.

I've checked a few carts that do this, but I'm not able to make sense of the functions they use, and I was wondering whether anybody had a simple method handy.

At the moment, I only have a brute-force method. My cart uses two straightforward variables: "lives" counts the player's lives, and "score" counts the score. Let's say I want to give the player an extra life for every 300 points they score. Right now, I only have this:

function gainlife()
 if score=300 then
  lives+=1
 elseif score=600 then
  lives+=1
 elseif score=900 then
  lives+=1
 end
end

It kinda works (assuming the player loses interest in the game after around 1,000 points). But I figure there HAS to be a way to capture the interval in a neater function. Unfortunately, my stupid brain can't figure it out!

Thank you for whatever wisdom you have to share.

P#73869 2020-03-13 04:00
[ :: Read More :: ]

Cart #hozitekeka-0 | 2020-03-12 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

Run it and watch the rubber band ball grow! That's it. Just a fun simulation.

Enjoy

-JH

P#73858 2020-03-12 21:17 ( Edited 2020-03-12 21:17)
[ :: Read More :: ]

Cart #lowknight-1 | 2020-11-28 | Code ▽ | Embed ▽ | No License
260

For some reason, I forgot to post this cartridge when it was originally made during the 2018 Demake Jam. Well, here it is now! This is the minified version, but the .p8 source is available on the itch.io page: https://krajzeg.itch.io/low-knight.

The game is a demake of and a homage to Hollow Knight. It was made in 6 days, so it's kind of rough around the edges, and the difficulty level is over the top. It is what it is, though, and still happy with how well it holds up given its development time :)

P#73854 2020-03-12 19:44 ( Edited 2020-11-28 18:52)
View Older Posts